package it.zqdszb.ui.activity;

import android.content.res.Configuration;
import android.os.Bundle;
import android.widget.ImageView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import it.videolibrary.video.videoplayer.builder.GSYVideoOptionBuilder;
import it.videolibrary.video.videoplayer.video.SampleControlVideo;
import it.videolibrary.video.videoplayer.video.StandardGSYVideoPlayer;
import it.zqdszb.R;
import it.zqdszb.entity.HotChannelBean;
import it.zqdszb.entity.PlayLinkListBean;
import it.zqdszb.library.utils.utils.StatusBarUtil;

/**
 * Created by GH on 2018-05-20.
 * 直播播放详情
 */

public class LivePlayActivity extends PlayBaseActivityDetail <StandardGSYVideoPlayer>{


	@BindView(R.id.detailPlayer)
	SampleControlVideo detailPlayer;

	HotChannelBean channel;
	List<PlayLinkListBean> playLinkList;

	private String url = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.fragment_live_play);
		initView();
	}

	@Override
	public StandardGSYVideoPlayer getGSYVideoPlayer() {
		return detailPlayer;
	}

	@Override
	public GSYVideoOptionBuilder getGSYVideoOptionBuilder() {
		ImageView imageView = new ImageView(this);
		//loadCover(imageView, url);
		return new GSYVideoOptionBuilder()
				.setThumbImageView(imageView)
				.setUrl(url)
				.setCacheWithPlay(true)
				.setVideoTitle(" ")
				.setIsTouchWiget(true)
				.setRotateViewAuto(false)
				.setLockLand(false)
				.setShowFullAnimation(true)//打开动画
				.setNeedLockFull(true)
				.setSeekRatio(1);
	}

	@Override
	public void clickForFullScreen() {

	}

	@Override
	public boolean getDetailOrientationRotateAuto() {
		return false;
	}




	private void initView() {
		channel= (HotChannelBean)getIntent().getSerializableExtra("channel");
		playLinkList= (ArrayList<PlayLinkListBean>)getIntent().getSerializableExtra("playLinkList");
		StatusBarUtil.setColor(this, getResources().getColor(R.color.black),0);

		resolveNormalVideoUI();
		initVideoBuilderMode();
	}
	private void resolveNormalVideoUI() {
		//增加title
	/*	detailPlayer.getTitleTextView().setVisibility(View.GONE);
		detailPlayer.getBackButton().setVisibility(View.GONE);*/
	}

	//重载后关闭重力旋转
	@Override
	public void onConfigurationChanged(Configuration newConfig) {
		super.onConfigurationChanged(newConfig);
		orientationUtils.setEnable(false);
	}
}
